home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 November: Tool Chest / Dev.CD Nov 94.toast / Sample Code / Snippets / Development Tools & Languages / ScreenShots from MacsBug / Read Me next >
Encoding:
Text File  |  1992-07-15  |  3.4 KB  |  64 lines  |  [TEXT/KAHL]

  1. TakeScreenShot Read Me File
  2.  
  3. 7-1-92 - Brigham Stevens
  4. Apple Computer Developer Technical Support
  5.  
  6. Normally, MacsBug or will not allow you to take a screen shot of your application's screen while
  7. you are in the debugger.  However, it is possible to work around this by adding a function to your
  8. program that takes a screen shot.  You can jump directly to this function from anywhere in your
  9. program using MacsBug commands and take a screen shot, and then continue with normal program
  10. execution.
  11.  
  12. This is especially useful to capture frames of an animation sequence when WaitNextEvent, 
  13. or GetNextEvent are not called.
  14.  
  15. Just include the function TakeScreenShot (in TakeScreenShot.c) in your code, and build your project
  16. with full MacsBug symbols on.  This function uses the built in screen shot FKEY to take a screen 
  17. shot to disk whenever it is called, at any time.  This will also save you the time in writing code 
  18. to create a PICT file of the screen, because this uses the standard System screen shot FKEY.
  19.  
  20. Since the code will be executing as part of your application, MacsBug will have restored the 
  21. screen, and also enabled interrupts, so you can take a screen shot and write to the disk.
  22.  
  23. When you are in the debugger and want to take a screen shot, enter in these commands: 
  24.  
  25. mc savePC PC
  26. g TakeScreenShot
  27.  
  28. This will put the value of the PC into a macro named savePC, and jump to the code in your
  29. application which loads the Screen Shot FKEY (FKEY id = 3) and performs a jsr to it.  
  30. This causes a screen shot to be taken and a file created, named Picture XX, just as if you had 
  31. pressed cmd-shift-3.  The last line of the function TakeScreenShot is a DebugStr.
  32.  
  33. This DebugStr will be interpreted as MacsBug commands to step over the next 2 instructions,
  34. which would be a movem to restore the registers used, and also an unlk to restore the stack,
  35. and then set the PC to the saved value.  (In other words, you forego the RTS, which would cause
  36. you to jump into never never land)  This leaves the stack in the state it was in before you 
  37. jumped to TakeScreenShot.  It is VERY important to set the MacsBug Macro to the program counter 
  38. before jumping to the TakeScreenShot function.  
  39.  
  40. You can also call the TakeScreenShot function directly from your code, which will work just fine,
  41. if you take out the last DebugStr, or set up a DebugStr before you call it that sets the savePC
  42. macro to the right address.
  43.  
  44. To simplify the use of this, you can create a macro that sets up the macro savePC and also 
  45. jumps to the TakeScreenShot routine.
  46.  
  47. MC ScreenShot 'mc savePC PC; g TakeScreenShot'
  48.  
  49. Then, whenever you want a screen shot from MacsBug, type in screenShot, and viola, you get one.  
  50. You can also add this to the DebuggerPrefs resource file with ResEdit, to add the Macro 
  51. permanently. This means changing or adding a resource of type 'mxbm'.  The resource file
  52. "TakeScreenShot MacsBug Macros" is already set up.  Just copy this into your DebuggerPrefs file,
  53. and then you can take screenshots by simply typing in ScreenShot within MacsBug.
  54.  
  55. One thing that could be done to improve this, is to
  56. rename the file from 'Picture 0' to something else, so that you can take as many screen shots as 
  57. needed without having to go to the Finder to rename them manually.
  58.  
  59. Feel free to send any comments, suggestions for improvement, improved versions, or general abuse.
  60.  
  61. - Brigham Stevens
  62.  
  63. AppleLink: BRIGHAM
  64. Internet: brigham@applelink.apple.com